package google.sites.view.menus.sites;


import com.google.gdata.data.sites.SiteEntry;
import dev.tools.view.dialogs.Dialog;
import dev.tools.view.dialogs.GridBagDialog;
import google.sites.model.Model;
import google.sites.view.View;

import javax.swing.*;
import java.awt.*;

/**
 * Created with IntelliJ IDEA.
 * User: Nuno
 * Date: 01-10-2013
 * Time: 17:14
 */
public class SitesListDialog extends GridBagDialog {
    public SitesListDialog() {
        super(View.INSTANCE);

        setComponent(0, 0, "Title");
        setComponent(1, 0, "Site name");
        setComponent(2, 0, "Theme");
    }

    @Override
    public void setVisible(boolean b) {
        super.setVisible(b);    //To change body of overridden methods use File | Settings | File Templates.

        int y = 1;
        try {
            for (SiteEntry entry : Model.INSTANCE.getSiteEntries()) {
                setComponent(0, y, entry.getTitle().getPlainText());
                setComponent(1, y, entry.getSiteName().getValue());
                setComponent(2, y, entry.getTheme().getValue());
                y++;
            }
        } catch (Exception e) {
            View.showError(e);
        }
    }
}
